package configuration

import (
	"encoding/json"
	"fmt"
	"kop/modules/configuration/client"
	"kop/modules/quest/configuration/questtype"
	"kop/util/log"
)

func init() {

	var err error
	if err = json.Unmarshal(client.Load("QuestMain"), &QuestConfigs); err != nil {
		panic(err)
	}

	log.Info("Load QuestMain.json success.")

}

// 主线任务配置
type (
	QuestConf struct {
		QuestID   int32 `json:"ID"`
		NextID    int32
		QuestType questtype.QuestType `json:"CheckType"`
		NeedValue int64               `json:"Value1"` // 参数1 需要的数量
		NeedID    int32               `json:"Value2"` // 参数2 具体ID
		Value3    int32               // 参数3 暂未使用
		AwardID   int32               // 奖励ID
	}
)

var (
	QuestConfigs = map[int32]QuestConf{}
)

func GetByQuestID(ID int32) QuestConf {

	var conf, ok = QuestConfigs[ID]
	if !ok {
		panic(fmt.Errorf("QuestID not found [%d]", ID))
	}

	return conf
}
